<?php
class retrieve_vehicle extends retrieve_base{

	private $module_display_options 	= array(
		Array("VEHICLE_LOCATION","Display the vehicles straight away (Vehicle Channel)"),
		Array("VEHICLE_LATEST","Display the latest vehicles in this location."),
		Array("VEHICLE_SEARCH","Display the vehicle search engine.")
	);

	/**
	* function produces abstract structure of modules db structure
	*
    * used to generate the table structure required abstract function that passes an abstract
	* representation of the desired table structure to the proper database module which will
	* interpet the abstract and convert it into a valid SQL Create table structure.
	*
	* @return Array list of abstract table definitions for this module
	*/
	function create_table(){
		$tables = array();
		/**
		* Table structure for table 'group_data'
		*/
		$fields = array(
			array("vehicle_identifier"			,"unsigned integer"			,"NOT NULL"	,"auto_increment"),
			array("vehicle_client"				,"unsigned integer"			,""			,"default '0'"),
			array("vehicle_manufacturer"		,"unsigned integer"			,""			,"default '0'"),
			array("vehicle_model"				,"unsigned integer"			,""			,"default '0'"),
			array("vehicle_year"				,"unsigned integer"			,"" 		,"default '0'"),
			array("vehicle_mileage"				,"unsigned integer"			,""			,"default '0'"),
			array("vehicle_price"				,"double"					,""			,"default '0'"),
			array("vehicle_engine_size"			,"varchar(20)"				,""	,"default ''"),
			array("vehicle_test"				,"unsigned small integer"	,""	,"default '0'"),
			array("vehicle_tax_year"			,"varchar(4)"				,""	,"default ''"),
			array("vehicle_tax_month"			,"varchar(2)"				,""	,"default ''"),
			array("vehicle_gearbox"				,"unsigned integer"			,""	,"default '0'"),
			array("vehicle_cab_type"			,"unsigned integer"			,""	,"default '0'"),
			array("vehicle_body_type"			,"unsigned integer"			,""	,"default '0'"),
			array("vehicle_extra_information"	,"text"						,""	,"default ''"),
			array("vehicle_licence_plate"		,"varchar(10)"				,""	,"default ''"),
			array("vehicle_date_created"		,"datetime"					,""	,"default NULL"),
			array("vehicle_status"				,"unsigned small integer"	,""	,"default '1'"),
			array("vehicle_chassis_number"		,"varchar(50)"				,""	,"default ''"),
			array("vehicle_customer"			,"varchar(50)"				,""	,"default ''"),
			array("vehicle_image_thumbnail"		,"unsigned small integer"	,""	,"default '0'"),
			array("vehicle_image_main"			,"unsigned small integer"	,""	,"default '0'"),
			array("vehicle_live"				,"unsigned small integer"	,""	,"default '0'"),
			array("vehicle_supplier"			,"varchar(50)"				,""	,"default ''")
		);
		
		
		$primary ="vehicle_identifier";
		$tables[count($tables)] = array("vehicle",$fields,$primary);
		/**
		* Table structure for table 'combo lookups'
		*/
		$insert_array = Array("body","cab","gears","manufacturer","model");
		for($index=0;$index<5;$index++){
			$val = $insert_array[$index];
			$fields = array(
			array("vehicle_".$val."_identifier"		,"unsigned integer"			,"NOT NULL"	,"auto_increment"),
			array("vehicle_".$val."_client"			,"unsigned integer"			,"NOT NULL"	,"default '0'"),
			array("vehicle_".$val."_description"	,"text"						,""			,"default ''")
			);
			if ($insert_array[$index]=="model"){
				$fields[count($fields)] = array("vehicle_model_manufacturer"	,"unsigned integer" ,"NOT NULL"		,"default '0'");
			}
			$primary ="vehicle_".$val."_identifier";
			$tables[count($tables)] = array("vehicle_".$val,$fields,$primary);
		}
		/**
		* Table structure for table 'combo lookups'
		-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
		
		
		*/
		$fields = array(
		array("vehicle_image_identifier"	,"unsigned integer"			,"NOT NULL"	,"auto_increment"),
		array("vehicle_image_client"		,"unsigned integer"			,"NOT NULL"	,"default '0'"),
		array("vehicle_image_type"			,"unsigned small integer"	,"NOT NULL"	,"default '0'"),
		array("vehicle_image_file"			,"varchar(255)"				,"NOT NULL"	,"default ''"),
		array("vehicle_image_vehicle"		,"unsigned integer"			,""			,"default ''"),
		array("vehicle_image_mime"			,"varchar(50)"				,""			,"default ''"),
		array("vehicle_image_size"			,"unsigned integer"			,""			,"default ''")
		);
		$primary ="vehicle_image_identifier";
		$tables[count($tables)] = array("vehicle_image",$fields,$primary);
		
		return $tables;
	}
}
?>